import Mock from 'mockjs'

// driverId = 224
// const fleetName = ''
const List = []
const count = 22


// getWaybillList()
for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    'id': 49,
    'lspId': 6,
    'fleetName': '运测测试车队',
    'fleetDescribe': '测试车队',
    'tenantId': 1,
    'gmtCreate': '@datetime("2018-MM-dd HH:mm:ss")',
    'gmtUpdate': '@datetime("2018-MM-dd HH:mm:ss")',
    'isDelete': null,
    'creator': '@email',
    'gmtModify': '@datetime("2018-MM-dd HH:mm:ss")',
    'lspName': '测试承运商',
    'carrierCount': 1,
    'trailerCount': 1,
    'driverCount': 1,
    'creatorLspName': '中联物流（中国）有限公司',
    'fleetIds': null,
    'fleetBindIds': null
  }))
}

export default {
  companyFleetList: config => { // 公司下的车队分页查询(lspm)
    // console.log('mock-shipOrderApi-getWaybillList()-config', config)
    const { current, size, condition } = JSON.parse(config.body)
    const mockList = List.filter(item => {
      if (condition !== undefined) {
        if (condition.fleetName !== '') return false
      }
      return true
    })
    const pageList = mockList.filter((item, index) => index < size * current && index >= size * (current - 1))
    // console.log('mock-shipOrderApi-geList()-pageList', pageList)
    const resData = {
      'code': 0,
      'data': {
        'total': mockList.length,
        'size': size,
        'pages': 0,
        'current': current,
        'records': pageList,
        'condition': {
          'fleetName': ''
        },
        'asc': true,
        orderByField: 'gmt_create',
        'offsetCurrent': 0
      },
      'message': 'success'
    }
    console.log('mock-shipOrderApi-geList()-resData', resData)
    return resData
  }
}

